package com.sip.dbadapter.dao.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 */
@Entity
@Table(name = "REPRESENTATION_TYPE")
public class RepresentationType implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long representationId;

    private Integer type;

    private String content;

    private Set<ConsumeType> consumeTypeSet;

    public RepresentationType() {

    }

    @Id
    @Column(name = "REPRESENTATION_ID", unique = true, nullable = false)
    @GeneratedValue
    public Long getRepresentationId() {

        return representationId;
    }

    @Column(name = "TYPE", nullable = false)
    public Integer getType() {

        return type;
    }

    @Column(name = "CONTENT")
    public String getContent() {

        return content;
    }

    @OneToMany(mappedBy = "representationType")
    public Set<ConsumeType> getConsumeTypeSet() {

        return consumeTypeSet;
    }

    public void setRepresentationId(Long representationId) {

        this.representationId = representationId;
    }

    public void setType(Integer type) {

        this.type = type;
    }

    public void setContent(String content) {

        this.content = content;
    }

    public void setConsumeTypeSet(Set<ConsumeType> consumeTypeSet) {

        this.consumeTypeSet = consumeTypeSet;
    }

    @Override
    public int hashCode() {

        int result = 0;
        result = (int) (31 * result + representationId);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (content != null ? content.hashCode() : 0);

        return result;
    }

    @Override
    public boolean equals(Object other) {

        if (this == other)
            return true;

        if (other == null || (this.getClass() != other.getClass())) {
            return false;
        }

        RepresentationType representationType = (RepresentationType) other;
        return (this.representationId == representationType.representationId) && (this.type != null && type.equals(representationType.type))
            && (this.content != null && content.equals(representationType.content));
    }

}
